<template>
  <div class="fastNavControl">
    <div class="control-section">
      <div class="control-header">
        <span>门店信息</span>
        <span @click="showBeautyBox = true">组件美化</span>
      </div>
      <div class="control-body">
        <div class="control-item">
          <div class="control-title">模板样式</div>
          <div class="control-content">
            <div class="example-list">
              <div
                :class="['example-item', params.params.style == 1 ? 'choose' : '']"
                @click.stop="changeStyle(1)"
              >
                <img src="@/assets/images/diy/shop_style_one.png" alt="" />
              </div>
              <div
                :class="['example-item', params.params.style == 2 ? 'choose' : '']"
                @click.stop="changeStyle(2)"
              >
                <img src="@/assets/images/diy/shop_style_two.png" alt="" />
              </div>
            </div>
          </div>
        </div>
        <div class="moudleNameBox">
          <titleControl
            :params="params.params"
            :initText="'附近门店'"
            :title="'模块标题'"
          ></titleControl>
        </div>
      </div>
    </div>
    <!-- 组件美化 -->
    <comBeautyBox
      :showBeautyBox="showBeautyBox"
      @handleBack="showBeautyBox = false"
    >
      <div>
        <!-- 背景 -->
        <bgControl :backgroudData="params.moduleCss"></bgControl>
        <spaceControl
          :spaceData.sync="params.moduleCss"
          @resetSpace="resetSpace"
          @resetMp="resetMp"
        ></spaceControl>
      </div>
    </comBeautyBox>
  </div>
</template>


<script>
import { fastNav } from "@/components/DiyNew/diy/dataConfig/config.js";
import bgControl from "@/components/DiyNew/diy/baseControl/bgControl/index.vue";
import comBeautyBox from "@/components/DiyNew/diy/comBeautyBox/comBeautyBox.vue";
import titleControl from "@/components/DiyNew/diy/baseControl/titleControl/index.vue";
import spaceControl from "@/components/DiyNew/diy/baseControl/spaceControl/index.vue";
export default {
  name: "shopInfoControl",
  components: {
    bgControl,
    comBeautyBox,
    titleControl,
    spaceControl
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      showBeautyBox: false,
      init: {},
    };
  },
  created() {
    let init = JSON.parse(JSON.stringify(fastNav));
    this.init = init;
  },
  methods: {
    changeStyle(e) {
      this.$setWithAction(this.params.params, "style", e)
    },
    // 重置圆角
    resetSpace(e) {
      let type = e.type;
      this.$set(this.params.moduleCss, type, 0);
    },
    // 重置边距
    resetMp() {
      this.$set(this.params.moduleCss, "margin", 0);
      this.$set(this.params.moduleCss, "padding", 0);
    }
  },
};
</script>


<style lang="scss" scoped>
.fastNavControl {
  height: calc(100vh - 54px);
  padding-bottom: 20px;
  ::-webkit-scrollbar {
    height: 0 !important;
    width: 0px !important;
  }
}
.control-section {
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  text-align: center;
  height: 100%;
  position: relative;
  .control-header {
    width: 100%;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    span:first-child {
      font-weight: 600;
      color: #000000;
    }
    span:last-child {
      font-size: 12px;
      color: #8c8c8c;
      cursor: pointer;
    }
  }
  .control-body {
    flex: auto;
    height: 0;
    overflow: auto;
    width: 228px;
    margin: 0 auto;
  }
}
.control-item {
  width: 100%;
  .control-title {
    padding: 24px 0 14px 0;
    font-size: 12px;
    color: #000000;
    text-align: left;
  }
  .flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .reset {
    font-size: 12px;
    color: #9e9e9e;
    cursor: pointer;
  }
  .control-content {
    .example-list {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      .example-item {
        cursor: pointer;
        position: relative;
        width: 70px;
        height: 58px;
        background: #f6f7f9;
        border-radius: 4px;
        margin-right: 9px;
        display: flex;
        justify-content: center;
        align-items: center;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .choose::before {
        content: '';
        position: absolute;
        width: 100%;
        height: 100%;
        border: 2px solid #1890fc;
        border-radius: 4px;
      }
      .example-item:nth-child(3n) {
        margin-right: 0;
      }
    }
  }
}
.control-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0 12px 0;
  font-size: 12px;
  font-weight: 400;
  color: #000000;
  .reset {
    font-size: 12px;
    font-weight: 400;
    color: #8e8e8e;
    cursor: pointer;
    user-select: none;
  }
  p {
    margin: 0;
  }
}
.moduleName {
  display: flex;
  align-items: center;
  justify-content: space-between;
  .nameText {
    width: 196px;
    height: 40px;
    background-color: #f6f7f9;
    border-radius: 4px;
    padding: 0 14px;
    input {
        width: 100%;
        height: 100%;
        border: none;
        outline: none;
        background-color: #f6f7f9;
    }
  }
  .show {
      width: 24px;
      height: 24px;
      background-color: #f6f7f9;
      border-radius: 4px;
      cursor: pointer;
      color: #000000;
  }
}
</style>